import subprocess
import sys
def run_command(command):
    result = subprocess.run(command, shell=True, text=True, capture_output=True)
    if result.returncode != 0:
        print(f"Error: {result.stderr}", file=sys.stderr)
        sys.exit(result.returncode)
    return result.stdout.strip()

class gl0906_git:
    def git_add(files):
        if not files:
            print("No files to add.")
            return
        run_command(f"git add {files}")

    def git_commit(message):
        if not message:
            print("Commit message cannot be empty.")
            return
        run_command(f'git commit -m "{message}"')

    def git_push(branch="release"):
        run_command(f"git push origin {branch}")

def main():
    # Example usage:
    files_to_add = "."  # Add all files, you can specify specific files or directories
    commit_message = "Your commit message"
    branch_name = "main"  # Specify your branch name here

    print("Adding files to git...")
    gl0906_git.git_add(files_to_add)

    print("Committing changes...")
    gl0906_git.git_commit(commit_message)

    print(f"Pushing changes to branch {branch_name}...")
    gl0906_git.git_push(branch_name)

    print("Git operations completed successfully.")

if __name__ == "__main__":
    main()
